package Demo_01;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class InsertDemo_01 {
    public static void main(String[] args) {
      /*  String driver = "com.mysql.jdbc.Driver";
        //数据库名在localhost上存在才可以

        String url = "jdbc:mysql://localhost:3306/jdbc?serverTimezone=UTC&characterEncoding=utf8&useUnicode=true&useSSL=false";
        String user = "root";
        String password = "root123";
        Connection conn = null;
        Statement stamt = null;
        try{
            Class.forName(driver);

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            System.out.println("驱动类不存在");

        }
        try {
             conn = DriverManager.getConnection(url,user,password);
            String sql = "update tbl_book_info set b_no='112' where b_no='123'";
            stamt = conn.createStatement();
            int r = stamt.executeUpdate(sql);
            if (r>0){
                System.out.println("执行成功");

            }


        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (stamt!=null){
            try {
                stamt.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            finally {
                stamt=null;
            }
        }
        if (conn!=null){
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            finally {
                conn=null;
            }
        }

    }
    public int update(String sql){


        return 0;
    }*/
    }
}
